<?php 
$weekarr = array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
$week = $weekarr[date("w")];
?>
<html>
<head>
    <title>Reminder</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <script type="text/javascript" src="<?=base_url()?>resource/js/jquery.js"></script>
    
    <link rel="stylesheet" href='<?=base_url()?>resource/css/style.css' type="text/css"/>
    
    <link rel="stylesheet" type="text/css" href="<?=base_url()?>resource/css/jquery.datetimepicker.css" />
    <script src="<?=base_url()?>resource/js/jquery.datetimepicker.js"></script>
    
    <link rel="stylesheet" type="text/css" href="<?=base_url()?>resource/css/jquery.autocompleter.css" />
    <script src="<?=base_url()?>resource/js/jquery.autocompleter.js"></script>
    <style>
        .input-div table tr{display:block;}
    </style>
</head>
<body>
    <div class="reminder-header">
        <h3><?=date("Y-m-d",$notice['noticedate'])?></h3>
    </div>
    <div class="positiondiv">
        <table>
            <tr>
                <td class="td-left">
                    <img src="<?=base_url()?>resource/img/home_ico.png" width="21" height="17">
                    Reminder > <a href="<?=base_url('reminder/reminders/'.date("Y-m-d",$notice['noticedate']).'/'.$ispickup)?>"><?=date("Y-m-d",$notice['noticedate'])?></a> > Detail
                </td>
                <td class="td-right">
                    <img src="<?=base_url()?>resource/img/menu2.png" width="27" height="24">Today is <?=$week?>,<?=date('M d,Y')?>
                </td>
            </tr>
        </table>
    </div>
    <div class="input-div" style="border:1px solid #C9C9C9;width:95%;border-radius:5px;margin:0px auto 20px;">
        <form action="<?=base_url('reminder/reminder_detail/'.$notice['id'].'/'.$ispickup)?>" method="post" onkeydown="if(event.keyCode==13)return false;" onsubmit="return checkform()">
            <input type='hidden' value="<?=date("Y-m-d",$notice['noticedate'])?>" name="noticedate" />
            <input type='hidden' name="association" id="association" value="<?=$notice['workerid']?>" />
            <table>
                <tr><td colspan="2"><h3>.Reminder</h3></td></tr>
                <tr><td class="nametd">Notice Date:</td><td><?=date("Y-m-d",$notice['noticedate'])?></td></tr>
                <tr><td class="nametd">Notice Time:</td><td><input type="text" name="noticetime" id="noticetime" style="width:80px;" value="<?=$notice['noticetime']?>" readonly="readonly"/><span class="err" id="timeerr">*</span></td></tr>
                <tr><td class="nametd">Notice Title:</td><td><input type="text" name="title" value="<?=$notice['title']?>" style="width:200px;"/><span class="err" id="titleerr">*</span></td></tr>
                <tr><td class="nametd">Notice Comment:</td><td><textarea name="comment" style="height:60px;width:200px;"><?=$notice['comment']?></textarea></td></tr>
                <tr><td class="nametd">Notice Type:</td>
                    <td>
                        <select name="type" id="type" style="width:120px;">
                            <option value="0">Normal
                            <option value="1">Airport pick-up
                            <option value="6">permit process
                            <option value="7">delivery
                            <option value="8">course
                        </select>
                    </td>
                </tr>
                <tr class="pickup" style="display:none;"><td class="nametd">Flight Number:</td><td><input type="text" name="fltno" value="<?=$notice['fltno']?>" style="width:200px;"/><span class="err" id="fltnoerr">*</span></td></tr>
                <tr class="pickup" style="display:none;"><td class="nametd">The Terminal:</td><td><input type="text" name="terminal" value="<?=$notice['terminal']?>" style="width:200px;"/><span class="err" id="terminalerr">*</span></td></tr>
                <tr class="pickup" style="display:none;"><td class="nametd">Arrive Time:</td><td><input type="text" name="arrivetime" value="<?=date('Y-m-d H:i',$notice['arrivetime'])?>" id="arrivetime" readonly="readonly" style="width:200px;"/><span class="err" id="arrivetimeerr">*</span></td></tr>
                <tr><td class="nametd">Candidate:</td><td><input type="text" name="candidate" id="candidate" readonly="readonly" value="<?=$notice['workername']?>" style="width:200px;"/><span class="err" id="candidateerr">*</span></td></tr>
                <tr>
                    <td class="nametd">Publicity:</td>
                    <td>
                        <input type="radio" name="ispublic" value="0" id="no" /><label for="no">No</label>
                        <input type="radio" name="ispublic" value="1" id="yes" /><label for="yes">Yes</label>
                    </td>
                </tr>
                <tr><td class="nametd"></td><td><input type='submit' value='Submit'/></td></tr>
            </table>
        </form>
    </div>
<script>
var type = "<?=$notice['type']?>";
$("#type").val(type);
if(type == 1){
   $(".pickup").css("display","block");
}
$("input[name='ispublic']:eq(<?=$notice['ispublic']?>)").attr("checked","checked");

$('#noticetime').datetimepicker({
    datepicker:false,
    format:'H:i',
    step:5
});

$('#arrivetime').datetimepicker({
    format:"Y-m-d H:i",
    step:10
});

$("#type").change(function(){
    var value = $(this).val();
    if(value == 1){
        $(".pickup").css("display","block");
    }else{
        $(".pickup").css("display","none");
    }
});

$("#candidate").click(function(){
    var iTop = (document.body.clientHeight-30-600)/2; //获得窗口的垂直位置;
    var iLeft = (document.body.clientWidth-10-800)/2; //获得窗口的水平位置;
    window.open('<?=base_url("profile/choice_workers/radio")?>','_blank',
    'width=800,height=600,menubar=no,toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=no,top='+iTop+',left='+iLeft);
});

function checkform(){
    var flag = true;
    if($("input[name='noticetime']").val() == ''){
        $("#timeerr").html("Please select notice time.");
        flag = false;
    }else{
        $("#timeerr").html("*");
    }
    
    if($.trim($("input[name='title']").val()) == ''){
        $("#titleerr").html("Please input title.");
        flag = false;
    }else{
        $("#titleerr").html("*");
    }
    
    var type = $("#type").val();
    if(type == 1){
        if($.trim($("input[name='fltno']").val()) == ''){
            $("#fltnoerr").html("Please input flight number.");
            flag = false;
        }else{
            $("#fltnoerr").html("*");
        }
        
        if($.trim($("input[name='terminal']").val()) == ''){
            $("#terminalerr").html("Please input the terminal.");
            flag = false;
        }else{
            $("#terminalerr").html("*");
        }
        
        if($("input[name='arrivetime']").val() == ''){
            $("#arrivetimeerr").html("Please select arrive time.");
            flag = false;
        }else{
            $("#arrivetimeerr").html("*");
        }
    }
    
    if($("input[name='candidate']").val() == ''){
        $("#candidateerr").html("Please select notice candidate.");
        flag = false;
    }else{
        $("#candidateerr").html("*");
    }
    return flag;
}
window.opener.location.reload();
</script>
</body>
</html>